<template>
    <div>
      <!--  改造实施信息 -->
      <h3>改造实施信息</h3>
      <aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig" :paramsObj="paramsObj" :key="theKey" @getTableData="refreshChange">
      </aplid-base-crud>
      <div class="total_money">
        <el-text type="primary">设备安装总费用：{{ totalMoney }} 元</el-text>
      </div>
    </div>
  </template>
  
  <script setup lang="ts">
  import { ref, reactive, toRefs, onMounted} from 'vue'
  import {baseConfig} from './config'
  import apiMod from '@/apiMod/index'
  
  
  let emits = defineEmits(['refresh'])
  let props = defineProps({
    nowRowData: {
      type: Object,
      default: () => ({})
    },
    type:{
      type: String,
      default: 'add'
    }
  })
  let crud = ref()
  let totalMoney = ref(0)

  let editData:any = ref({})
  let paramsObj = ref({
          idCard: props.nowRowData.idCard,
          telephone:props.nowRowData.telephone,
          mainId :props.nowRowData.mainId,
          belongYear:props.nowRowData.belongYear
  })

  let theKey = ref(0)
  // 计算金额总量
  const getTotalMoney = ()=>{
    apiMod.view_bscAdaptDevice_amount({idCard:props.nowRowData.idCard||editData.value.idCard,mainId:props.nowRowData.mainId||editData.value.mainId}).then(res=>{
      totalMoney.value = res.data
    })
  }
  const refreshChange = () =>{
    let ysq = setTimeout(()=>{
      getTotalMoney()
      clearTimeout(ysq)
    },500)
  }
  getTotalMoney()
  
  </script>
  <style scoped lang="scss">
  .btn_part{
    margin:0 auto;
    width: 20%;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center
  }
  .total_money{
    margin-top: 20px;
    width: 100%;
    display: flex;
    flex-direction: row-reverse;
    align-self:center
  }
  </style>